package com.jarhow.gojekhook.eleme;

import com.jarhow.gojekhook.Utils.AbstractHook;
import com.jarhow.gojekhook.Utils.Xlog;
import com.jarhow.gojekhook.Utils.XposedUtils;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;

public class HookAppUCWeb extends AbstractHook {
    @Override
    public void doHook() {
//        XposedHelpers.findAndHookMethod("me.ele.component.webcontainer.view.AppUCWeb2Activity", classloader, "loadWebUrl", java.lang.String.class, new XC_MethodHook() {
//            @Override
//            protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
//                super.beforeHookedMethod(param);
//                try {
//                    Xlog.d(tag,"loadUrl and the Url is: "+param.args[0]);
//                    XposedUtils.printCallers();
//                }catch (Exception e){
//
//                }
//
//            }
//            @Override
//            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
//                super.afterHookedMethod(param);
//            }
//        });
//        XposedHelpers.findAndHookMethod("com.uc.webview.export.WebView", classloader, "loadUrl", java.lang.String.class, new XC_MethodHook() {
//            @Override
//            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
//                super.beforeHookedMethod(param);
//                try {
//                    Xlog.d(tag,"webview loadUrl and the Url is: "+param.args[0]);
//                    XposedUtils.printCallers();
//                }catch (Exception e){
//
//                }
//
//            }
//            @Override
//            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
//                super.afterHookedMethod(param);
//            }
//        });
//        try {
//            XposedHelpers.findAndHookMethod("me.ele.component.web.g", classloader, "d", java.lang.String.class, new XC_MethodHook() {
//                @Override
//                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
//                    super.afterHookedMethod(param);
//                    String check = (String)param.args[0];
//                    Xlog.d(tag,"this url:"+check +"____________________________need checked!!!!");
//                    XposedUtils.printCallers(tag);
//                }
//            });
//        }catch (Exception e){
//            Xlog.e(tag,"Hook url check failed:"+e.toString());
//        }
        try {
            XposedHelpers.findAndHookMethod("com.alibaba.ut.utils.Logger", classloader, "w", java.lang.String.class, java.lang.Object[].class, new XC_MethodHook() {

                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    super.afterHookedMethod(param);
                    Xlog.d(tag,"logger w:{"+(String)param.args[0]+"}");
                }
            });



            XposedHelpers.findAndHookMethod("android.taobao.windvane.jsbridge.WVBridgeEngine", classloader, "nativeCall", java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, new XC_MethodHook() {

                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    super.afterHookedMethod(param);
                    Xlog.d(tag,"nativeCall param1:{"+(String)param.args[0]+"}");
                    Xlog.d(tag,"nativeCall param2:{"+(String)param.args[1]+"}");
                    Xlog.d(tag,"nativeCall param3:{"+(String)param.args[2]+"}");
                    Xlog.d(tag,"nativeCall param4:{"+(String)param.args[3]+"}");
                }
            });

        }catch (Exception e){
            Xlog.e(tag,"Hook windvane failed:"+e.toString());
        }

        try {
            XposedHelpers.findAndHookMethod("com.alibaba.ut.comm.JsBridge", classloader, "CALL", java.lang.String.class, new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    super.afterHookedMethod(param);
                    Xlog.d(tag,"CALL params:{" + (String)param.args[0] + "}");
                }
            });


        }catch (Exception e){
            Xlog.e(tag,"Hook UT4APlus failed:"+e.toString());
        }








    }
}
